import fetch from 'utils/fetch';



// 学校的模糊搜索，根据学校名称查询学校
export function getSchoolListBySchoolName(schoolName) {
    const data = {
        schoolName
    };
    return fetch({
        url: '/cookbook/querySchoolByName',
        method: 'post',
        data
    })
}


// 获取所有食谱列表
export function getRecipeListAll(curPage,pageSize) {
    const data = {
        curPage,
        pageSize
    };
    return fetch({
        url: '/cookbook/pageAll',
        method: 'post',
        data
    })
}



// 删除已发布的食谱
export function delRecipeByRecipeId(pId) {
    const data = {
        pId
    };
    return fetch({
        url: '/cookbook/deleteCookbook',
        method: 'post',
        data
    })
}

// 根据学校id，开始时间和结束时间，发布时间，页码查询食谱列表
export function getRecipeListByPage(fSchoolId, curPage, pageSize, createTime, startTime, endTime) {
    const data = {
        fSchoolId,
        curPage,
        pageSize,
        createTime,
        startTime,
        endTime,
    };
    return fetch({
        url: '/cookbook/getCookbooksByPage',
        method: 'post',
        data
    })

}

// 根据食谱ID获取食谱详情
export function getRecipeDetailByRecipeId(pId) {
    const data = {
        pId
    };
    return fetch({
        url: '/cookbook/selectCookbookDetail',
        method: 'post',
        data
    })
}


// 获取食谱详情的适用时间
export function getRecipeDetailSuitTimeByRecipeId(pId){
    const data = {
        pId
    };
    return fetch({
        url: '/cookbook/suitTime',
        method: 'post',
        data
    })
}
// 发布食谱
export function addNewRecipe(suitTime,fSchoolId ,cookbookDetail) { // startTime ,endTime ,sCreateTime ,
    const data = {
        // startTime,
        // endTime,    
        // sCreateTime,
        suitTime,
        fSchoolId,
        cookbookDetail
    };   
    return fetch({
        url: '/cookbook/saveCookbook',
        method: 'post',
        data
    })
}

// 判断判断可以发布什么时候的食谱
export function checkRecipeCycle(fSchoolId) {
    const data = {
        fSchoolId
    };
    return fetch({
        url: '/cookbook/saveTime',
        method: 'post',
        data
    })
}

//查看历史菜谱
export function getRecipeHistoryList(fSchoolId) {
    const data = {
        fSchoolId
    };
    return fetch({
        url: '/cookbook/selectCookbookHistory',
        method: 'post',
        data
    })
}

